<?php defined('_JEXEC') or die('Restricted access');
function strip_string_length($str,$length){
	if (strlen($str) <= $length)
		return $str;
	$str = substr($str,0,$length);
	$str = substr($str,0,strripos($str," "));
	return $str;
}
?>

<div class="raovat-list">
	<?php echo $this->menu;?>
	<?php
	$region = array(1=>'Toàn quốc',2=>'TP Hà Nội',3=>'TP Hồ Chí Minh',4=>'Các tỉnh phía Bắc',5=>'Các tỉnh phía Nam')
	?>
	<?php if ($this->data){?>
	<ul class="list-article"><?php 	
		foreach ($this->data as $article){
			
			echo "<li>
				<div class='title'>
				<a href='".JRoute::_('index.php?option=com_raovat&view=raovat&id='.$article->id)."'>{$article->title}</a>";
			if ($article->image){
				echo "<div class='image'><img src='images/".$article->image."'/></div>";
				echo "<div class='description'>".strip_string_length(strip_tags($article->description),250)."</div>";
			}
			echo "</div>";
			echo "<div class='date'>".date('d/m',strtotime($article->registe_date))."</div>";
			echo "<div class='region'>".$region[$article->region]."</div>";
			echo "</li>";
		}
	?></ul><?php }?>
	
	<div class="pagination">
		<?php echo $this->pagination->getPagesLinks(); ?>
	</div>

</div>